Repository navigation
Document Euler method accuracy comparison - #111
Open
pruthvirajgojare-source wants to merge 1 commit into
Open
pruthvirajgojare-source wants to merge 1 commit into
pruthvirajgojare-source wants to merge 1 commit into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Documents the error behavior of explicit Euler alongside modified Euler and classical RK4 for
dy/dx = y,y(0) = 1on[0, 1]. This makes the accuracy-versus-step-size tradeoff clearer for learners and adds a doctest that demonstrates the methods' observed convergence orders.Related Issue
None identified.
Fixes: N/A (no related issue)
Type of Change
Changes Made
maths/euler_method.py.work/R23-T047/compare_test.pyto exercise the three solvers on 11 shared inputs, including the requested step sizes 0.1, 0.05, and 0.025, and to benchmark them on the same cases.work/R23-T047/COMPARE.mdwith API differences, error results, timings, and a beginner recommendation.For the requested initial-value problem, the measured observed orders were 0.9533 (explicit Euler), 1.9591 (modified Euler), and 3.9550 (RK4), consistent with O(h), O(h^2), and O(h^4).
Screenshots / Recordings
Not applicable; this PR changes algorithm documentation and test evidence, not the UI.
Testing
uv run pytest work/R23-T047/compare_test.py— passed, 12 tests.uv run pytest maths/euler_method.py maths/euler_modified.py maths/numerical_analysis/runge_kutta.py --doctest-modules— passed, 3 modules.uv run python -m doctest -v maths/euler_method.py— passed, 11 examples.uvx ruff check maths/euler_method.py work/R23-T047/compare_test.py— passed.uvx ruff format --check maths/euler_method.py work/R23-T047/compare_test.py— passed.Checklist
Additional Notes
On the tested macOS arm64 / Python 3.15.0rc3 free-threading environment, the median times were 6.03 us/solve for explicit Euler, 12.49 us/solve for modified Euler, and 17.72 us/solve for RK4. These timings are machine-dependent. Explicit Euler is recommended as a beginner's starting point for its simple update; the other two methods illustrate higher accuracy at additional per-step cost.